<template>
  <div id="index" ref="appRef">
    <div class="bg">
      <dv-loading v-if="loading">Loading...</dv-loading>
      <div v-else class="host-body" style="display: flex">
        <div class="item" @click="goRouter('enterprise')">企业</div>
        <div class="item" @click="goRouter('people')">人</div>
        <div class="item" @click="goRouter('scenicSpot')">景</div>
        <div class="item" @click="goRouter('crew')">组</div>
      </div>
    </div>
  </div>
</template>

<script>
import drawMixin from "../utils/drawMixin";
import { formatTime } from '../utils/index.js'


export default {
  mixins: [ drawMixin ],
  data() {
    return {
      timing: null,
      loading: true,
      dateDay: null,
      dateYear: null,
      dateWeek: null,
      weekday: ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
    }
  },
  components: {},
  mounted() {
    this.timeFn()
    this.cancelLoading()
  },
  unMounted() {
    clearInterval(this.timing)
  },
  methods: {
    timeFn() {
      this.timing = setInterval(() => {
        this.dateDay = formatTime(new Date(), 'HH: mm: ss')
        this.dateYear = formatTime(new Date(), 'yyyy-MM-dd')
        this.dateWeek = this.weekday[new Date().getDay()]
      }, 1000)
    },
    cancelLoading() {
      setTimeout(() => {
        this.loading = false
      }, 500)
    },
    goRouter(name){
      if(name==='people'){
        this.$http.get(this.$apis.systemDict.findMultiDataTreesByCode, {typeCode:'person_type'}).then(res => {
          console.log(res)
        })
        return
      }
      this.$router.push({name: name})
    }
  }
}
</script>

<style lang="scss">
@import '../assets/scss/index.scss';
  .host-body .item { width: 200px; line-height: 30px;}
</style>
